package com.ruoyi.system.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.db.domain.system.PcRaiseRecord;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiImplicitParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.service.IPcRaiseRecordService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 【请填写功能名称】Controller
 * 
 * @author ruoyi
 * @date 2022-08-03
 */
@Api(value = "【请填写功能名称】",tags ="【请填写功能名称】")
@RestController
@RequestMapping("/raise/record")
public class PcRaiseRecordController extends BaseController
{
    private static Logger log = LoggerFactory.getLogger(PcRaiseRecordController.class);
    @Autowired
    private IPcRaiseRecordService pcRaiseRecordService;

    /**
     * 查询【请填写功能名称】列表
     */
    @ApiOperation(value = "查询【请填写功能名称】列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name="pcRaiseRecord",value="【请填写功能名称】",paramType="form")
    })
    @RequiresPermissions("system:record:list")
    @GetMapping("/list")
    public TableDataInfo list(PcRaiseRecord pcRaiseRecord)
    {
        try {
            startPage();
            List<PcRaiseRecord> list = pcRaiseRecordService.selectPcRaiseRecordList(pcRaiseRecord);
            return getDataTable(list);
        }catch (Exception e){
            log.error("【请填写功能名称】发生异常",e);
        }
        return null;
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @ApiOperation(value = "导出【请填写功能名称】列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name="pcRaiseRecord",value="【请填写功能名称】",dataType="PcRaiseRecord")
    })
    @RequiresPermissions("system:record:export")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response,@RequestBody PcRaiseRecord pcRaiseRecord)
    {
        try {
            List<PcRaiseRecord> list = pcRaiseRecordService.selectPcRaiseRecordList(pcRaiseRecord);
            ExcelUtil<PcRaiseRecord> util = new ExcelUtil<PcRaiseRecord>(PcRaiseRecord.class);
            util.exportExcel(response, list, "【请填写功能名称】数据");
        }catch (Exception e){
            log.error("【请填写功能名称】发生异常",e);
        }
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @ApiOperation(value = "获取【请填写功能名称】详细信息")
    @ApiImplicitParam(name="id",value="【请填写功能名称】")
    @RequiresPermissions("system:record:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        try {
            return AjaxResult.success(pcRaiseRecordService.selectPcRaiseRecordById(id));
        }catch (Exception e){
            log.error("【请填写功能名称】发生异常",e);
        }
        return AjaxResult.error("【请填写功能名称】异常");
    }

    /**
     * 新增【请填写功能名称】
     */
    @ApiOperation(value = "新增【请填写功能名称】")
    @ApiImplicitParams({
            @ApiImplicitParam(name="pcRaiseRecord",value="【请填写功能名称】",dataType="PcRaiseRecord")
    })
    @RequiresPermissions("system:record:add")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PcRaiseRecord pcRaiseRecord)
    {
        try {
            int i=pcRaiseRecordService.insertPcRaiseRecord(pcRaiseRecord);
            return toAjax(i);
        }catch (Exception e){
            log.error("新增【请填写功能名称】发生异常",e);
        }
        return AjaxResult.error("【请填写功能名称】异常");
    }

    /**
     * 修改【请填写功能名称】
     */
    @ApiOperation(value = "修改【请填写功能名称】")
    @ApiImplicitParams({
            @ApiImplicitParam(name="pcRaiseRecord",value="【请填写功能名称】",dataType="PcRaiseRecord")
    })
    @RequiresPermissions("system:record:edit")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PcRaiseRecord pcRaiseRecord)
    {
        try {
            int i=pcRaiseRecordService.updatePcRaiseRecord(pcRaiseRecord);
            return toAjax(i);
        }catch (Exception e){
            log.error("修改【请填写功能名称】发生异常",e);
        }
        return AjaxResult.error("【请填写功能名称】异常");
    }

    /**
     * 删除【请填写功能名称】
     */
    @ApiOperation(value = "删除【请填写功能名称】")
    @ApiImplicitParam(name="ids",value="【请填写功能名称】")
    @RequiresPermissions("system:record:remove")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        try {
            int i=pcRaiseRecordService.deletePcRaiseRecordByIds(ids);
            return toAjax(i);
        }catch (Exception e){
            log.error("删除【请填写功能名称】发生异常",e);
        }
        return AjaxResult.error("【请填写功能名称】异常");
    }
}
